#include "form4_1.h"
#include "ui_form4_1.h"

Form4_1::Form4_1(Widget *las,Flight &f,FlightBookingSystem &system,QWidget *parent)
    : last(las),
    flight(f),
    bookingSystem(system),
    QWidget(parent),
    ui(new Ui::Form4_1)
{
    ui->setupUi(this);
}

Form4_1::~Form4_1()
{
    delete ui;
}

void Form4_1::on_lineEdit1_textChanged(const QString &arg1)
{
    string s=arg1.toStdString();
    this->flight.destination=s;
}


void Form4_1::on_lineEdit2_textChanged(const QString &arg1)
{
    int s=arg1.toInt();
    this->flight.dayOfWeek=s;
}


void Form4_1::on_lineEdit3_textChanged(const QString &arg1)
{
    int s=arg1.toInt();
    this->flight.capacity=s;
}


void Form4_1::on_pushButton_clicked()
{
    this->flight.remainingTickets=this->flight.capacity;
    //更新数据文件，修改航班数据
    bookingSystem.modifyFlight(flight.flightNumber,flight.airplaneNumber,flight);
    this->page4_2=new Form4_2;
    connect(this->page4_2,SIGNAL(back()),this->last,SLOT(comeBackToPrev4_2()));
    this->close();
    this->page4_2->show();
}

